OpenStack Newton : How to use Heat
2016/12/22 |
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
| +------------------+ | +------------------------+ | [ Control Node ] | | | [ Network Node ] | | Keystone |10.0.0.30 | 10.0.0.50| DHCP,L3,L2 Agent | | Glance |------------+------------| Metadata Agent | | Nova API |eth0 | eth0| Heat API,API-CFN | | Neutron Server | | | Heat Engine | +------------------+ | +------------------------+ eth0|10.0.0.51 +--------------------+ | [ Compute Node ] | | Nova Compute | | L2 Agent | +--------------------+ |
[1] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
heat_template_version: 2016-10-14 description: Heat Sample Template parameters: ImageID: type: string description: Image used to boot a server NetID: type: string description: Network ID for the server resources: server1: type: OS::Nova::Server properties: name: "Heat_Deployed_Server" image: { get_param: ImageID } flavor: "m1.small" networks: - network: { get_param: NetID } outputs: server1_private_ip: description: IP address of the server in the private network value: { get_attr: [ server1, first_address ] }
root@dlp ~(keystone)#
openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 7d0cf100-6017-448c-9a6b-5bcf20d93f73 | Ubuntu1604 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +---------------------------------+---------+----------------------------------+ | ID | Name | Subnets | +---------------------------------+---------+----------------------------------+ | 05e48f19-b637-4a0f-829f- | ext_net | 1587abf4-a271-42a2-97eb- | | d25739cfcefe | | 538f864e104b | | 75e0a881-d371-4dcf- | int_net | 28daf4f0-3076-4976-aa82-5d489f53 | | 8d65-3a412d28e9a7 | | 70a4 | +---------------------------------+---------+----------------------------------+root@dlp ~(keystone)# Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'`
# create an instance from the template root@dlp ~(keystone)# openstack stack create -t sample-stack.yml --parameter "ImageID=Ubuntu1604;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 9654bab6-8053-49c8-9c61-b6df231f9885 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2016-12-23T08:02:26Z | | updated_time | None | | stack_status | CREATE_IN_PROGRESS | | stack_status_reason | Stack CREATE started | +---------------------+--------------------------------------+ # turn to "CREATE_COMPLETE" after few minutes later like follows root@dlp ~(keystone)# heat stack-list +---------------+--------------+---------------+----------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +---------------+--------------+---------------+----------------+--------------+ | 9654bab6-8053 | Sample-Stack | CREATE_COMPLE | 2016-12-23T08: | None | | -49c8-9c61-b6 | | TE | 02:26Z | | | df231f9885 | | | | | +---------------+--------------+---------------+----------------+--------------+ # the instance is running which is created from the Heat template root@dlp ~(keystone)# openstack server list +-----------------+-----------------+---------+-------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------------+-----------------+---------+-------------------+------------+ | 9e7d28c7-beb6-4 | Heat_Deployed_S | ACTIVE | int_net=192.168.1 | Ubuntu1604 | | f02-bdbc- | erver | | 00.10 | | | e3d799694e69 | | | | | | 94afe31b-659b-4 | Ubuntu_1604 | SHUTOFF | int_net=192.168.1 | Ubuntu1604 | | f61-bfd4-380bf4 | | | 00.9, 10.0.0.207 | | | 40b510 | | | | | +-----------------+-----------------+---------+-------------------+------------+ # delete the instance likwe follows if you don't need root@dlp ~(keystone)# openstack stack delete --yes Sample-Stack Are you sure you want to delete this stack(s) [y/N]? y +--------------------------------------+--------------+-----------------+---------------------+--------------+ | id | stack_name | stack_status | creation_time | updated_time | +--------------------------------------+--------------+-----------------+---------------------+--------------+ | 5040ab16-54cb-468b-ae4a-0b474a4930ac | Sample-Stack | CREATE_COMPLETE | 2016-06-09T11:28:33 | None | +--------------------------------------+--------------+-----------------+---------------------+--------------+root@dlp ~(keystone)# openstack stack list +----+------------+--------------+---------------+ | id | stack_name | stack_status | creation_time | +----+------------+--------------+---------------+ +----+------------+--------------+---------------+ |
[2] |
The guide for writing templates are opened on the official site below.
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html |